/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Current.BattleUpgradesLib;

import Current.BattleUpgradesLib.Upgrades.DefenseBattleUpgrade;

import java.io.Serializable;

/**
 * @author Fork
 */
public class DefenseUpgrades implements Serializable, Cloneable {

    private DefenseBattleUpgrade defUpgrades;
    private Integer expertGuards;

    public DefenseUpgrades(DefenseBattleUpgrade defUpgrades, Integer expertGuards) {
        this.defUpgrades = defUpgrades;
        this.expertGuards = expertGuards;
    }

    public DefenseUpgrades(Integer expertGuards) {
        this.defUpgrades = new DefenseBattleUpgrade(0, 0, 0, 0);
        this.expertGuards = expertGuards;
    }

    public DefenseBattleUpgrade getDefUpgrades() {
        return defUpgrades;
    }

    public void setDefUpgrades(DefenseBattleUpgrade defUpgrades) {
        this.defUpgrades = defUpgrades;
    }

    public Integer getExpertGuards() {
        return expertGuards;
    }

    public void setExpertGuards(Integer expertGuards) {
        this.expertGuards = expertGuards;
    }

    public Integer getDefenseFromUpgrades() {
        Integer aux = 0;
        if (this.defUpgrades.getCapacity() > 0) {
            if (this.defUpgrades.getHave() >= (int) Math.floor(expertGuards / this.defUpgrades.getCapacity())) {
                aux = this.defUpgrades.getDefenseBonus() * (int) Math.floor(expertGuards / this.defUpgrades.getCapacity());
            } else {
                aux = this.defUpgrades.getDefenseBonus() * this.defUpgrades.getHave();
            }
        }
        return aux;
    }
}    
